package com.yape.stockService.impl;

import com.yape.stockService.IStockNewsService;
import com.yape.dao.IStockNewsDao;
import com.yape.po.StockNews;
import com.yape.vo.StockNewsVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yape
 * @description
 * @date 2025/5/24 22:22
 */
@Service
public class StockNewsService implements IStockNewsService {


    @Resource
    private IStockNewsDao stockNewsDao;

    @Override
    public List<StockNewsVO> queryStockNews() {
        List<StockNews> stockNews = stockNewsDao.queryStockNews();

        List<StockNewsVO> stockNewsVOList = stockNews.stream()
                .map(e -> StockNewsVO.builder()
                        .id(e.getId())
                        .title(e.getTitle())
                        .url(e.getUrl())
                        .publishTime(e.getPublishTime())
                        .build())
                .toList();

        return stockNewsVOList;
    }
}
